package com.sskj.finance.ui.activity;


import android.support.v4.app.Fragment;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;

import com.alibaba.android.arouter.facade.annotation.Autowired;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.android.arouter.launcher.ARouter;
import com.bulong.rudeness.RudenessScreenHelper;
import com.hey.lib.HeySpinner;
import com.shizhefei.mvc.MVCCoolHelper;
import com.shizhefei.view.coolrefreshview.CoolRefreshView;
import com.sskj.common.adapter.slimadapter.IViewInjector;
import com.sskj.common.adapter.slimadapter.SlimAdapter;
import com.sskj.common.adapter.slimadapter.SlimInjector;
import com.sskj.common.base.App;
import com.sskj.common.box.decoration.DividerLineItemDecoration;
import com.sskj.finance.R;
import com.sskj.finance.R2;
import com.sskj.finance.presenter.MortgageRecordActivityPresenter;
import com.sskj.lib.Constans;
import com.sskj.lib.RConfig;
import com.sskj.lib.RxBusCode;
import com.sskj.lib.base.BaseActivity;
import com.sskj.lib.box.LiveDataBus;
import com.sskj.lib.mvchelper.ModelRx2DataSource;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import io.reactivex.Flowable;

@Route(path = RConfig.FINAN_MORTGAGE_RECORD)//抵押记录
public class MortgageRecordActivity extends BaseActivity<MortgageRecordActivityPresenter> {
    @BindView(R2.id.spinnerType)
    HeySpinner spinnerType;
    @BindView(R2.id.spinnerStatus)
    HeySpinner spinnerStatus;
    @Autowired
    String pid;


    @Override
    protected int getLayoutId() {
        return R.layout.finan_activity_mortgage_record;
    }

    @Override
    public MortgageRecordActivityPresenter getPresenter() {
        return new MortgageRecordActivityPresenter();
    }

    @Override
    protected void initView() {
        ARouter.getInstance().inject(this);
        setTitle(App.INSTANCE.getString(R.string.finan_mortgageRecordActivity1_j));
        ArrayList<String> typeStr = new ArrayList<>();
        typeStr.add(App.INSTANCE.getString(R.string.finan_mortgageRecordActivity2_j));
        typeStr.add(App.INSTANCE.getString(R.string.finan_borrowActivity2_j));
        typeStr.add(App.INSTANCE.getString(R.string.finan_borrowActivity1_j));
        ArrayList<String> statusStr = new ArrayList<>();
        statusStr.add(App.INSTANCE.getString(R.string.finan_mortgageRecordActivity2_j));
        statusStr.add(App.INSTANCE.getString(R.string.finan_mortgageRecordActivity5_j));
        statusStr.add(App.INSTANCE.getString(R.string.finan_mortgageRecordActivity6_j));
        spinnerStatus.attachData(statusStr);
        spinnerType.attachData(typeStr);
        spinnerType.setOnSelectListener(position -> {
            if (position == 0) {
                LiveDataBus.get().with(RxBusCode.UPDATE_DYKF_TYPE).postValue(null);
            } else {
                LiveDataBus.get().with(RxBusCode.UPDATE_DYKF_TYPE).postValue(position + "");
            }
        });
        spinnerStatus.setOnSelectListener(position -> {
            if (position == 0) {
                LiveDataBus.get().with(RxBusCode.UPDATE_DYKF_STATUS).postValue(null);
            } else {
                LiveDataBus.get().with(RxBusCode.UPDATE_DYKF_STATUS).postValue(position + "");
            }
        });
        getSupportFragmentManager()
                .beginTransaction()
                .replace(R.id.frameLayout, (Fragment) ARouter.getInstance().build(RConfig.FINAN_FRAGMENT_DYJK).withString(Constans.PID, pid).navigation())
                .commit();
    }
}
